import Vue from 'vue'
import Router from 'vue-router'
import App from '../views/Index'

Vue.use(Router)

let routes = [
  {
    path: '/',
    name: 'app',
    component: App,
    redirect: {
      name: 'home'
    },
    children: [
      {
        path: 'home',
        name: 'home',
        component: () => import('../views/Home.vue')
      },
      {
        path: 'login',
        name: 'login',
        component: () => import('../views/sign/login'),
        meta: { isFooter: false, title: '登录' }
      },
      {
        path: 'register',
        name: 'register',
        component: () => import('../views/sign/register'),
        meta: { isFooter: false, title: '注册' }
      },
      {
        path: 'forgetpassword',
        name: 'forgetPassword',
        component: () => import('../views/sign/forgetPassword'),
        meta: { isFooter: false, title: '忘记密码' }
      }
      // {
      //   path: 'series',
      //   name: 'series',
      //   component: () => import('../views/app/Series.vue')
      // },
      // {
      //   path: 'k12',
      //   name: 'k12',
      //   component: () => import('../views/app/K12.vue')
      // },
      // {
      //   path: 'devPlatform',
      //   name: 'devPlatform',
      //   component: () => import('../views/app/DevPlatform.vue')
      // }, {
      //   path: 'detail/:pid',
      //   name: 'detail',
      //   component: () => import('../views/app/Detail.vue')
      // }, {
      //   path: 'search',
      //   name: 'search',
      //   component: () => import('../views/app/Search.vue')
      // },
      // {
      //   path: 'seriesList',
      //   name: 'seriesList',
      //   component: () => import('../views/app/SeriesList.vue')
      // }, {
      //   path: 'seriesDetail',
      //   name: 'seriesDetail',
      //   component: () => import('../views/app/SeriesDetail.vue')
      // },
      // {
      //   path: 'login',
      //   name: 'login',
      //   component: () => import('../views/app/Login.vue')
      // },
      // {
      //   path: 'register',
      //   name: 'register',
      //   component: () => import('../views/app/Register.vue')
      // },
      // {
      //   path: 'registerSuccess',
      //   name: 'registerSuccess',
      //   component: () => import('../views/app/RegisterSuccess.vue')
      // },
      // {
      //   path: 'forgetPw',
      //   name: 'forgetPw',
      //   component: () => import('../views/app/ForgetPw.vue')
      // },
      // {
      //   path: 'resetPwSuccess',
      //   name: 'resetPwSuccess',
      //   component: () => import('../views/app/ResetPwSuccess.vue')
      // },
      // {
      //   path: 'trialApplication',
      //   name: 'trialApplication',
      //   component: () => import('../views/app/TrialApplication.vue')
      // },
      // {
      //   path: 'trialApplySuccess',
      //   name: 'trialApplySuccess',
      //   component: () => import('../views/app/TrialApplySuccess.vue')
      // },
      // {
      //   path: 'personal',
      //   name: 'personal',
      //   component: () => import('../views/app/Personal.vue')
      // },
      // {
      //   path: 'checkMore',
      //   name: 'checkMore',
      //   component: () => import('../views/app/CheckMore.vue')
      // }
    ]
  }
]
let router = new Router({
  mode: 'history',
  base: '/',
  routes,
  scrollBehavior (to, from, savedPosition) {
    // return 期望滚动到哪个的位置
    return { x: 0, y: 0 }
  }
})

router.beforeEach((to, from, next) => {
  window.scrollTo(0, 0)
  next()
})

export default router
